<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
    <%= title %>
<form >
  <label for="username">用户名</label><input id="user" name="username" type="text"><br>
  <label for="password">密码</label><input id="psd" name="password" type="text"><br>
  <a href="javascript:;" id="login">登录</a>
</form>
</body>
</html>
<script src="/javascripts/jquery-1.11.1.min.js"></script>
<script>
  $('#login').click(function(){
      $.ajax({
        url: '/api/useLogin',
        type:"post",
        dataType: 'JSON',
        data:{
          username:$('#user').val(),
          password:$('#psd').val()
        },
        success:function(data){
          console.log(data.code)
          alert(data.msg)
          if(data.code ==0) {
            window.location.href = '/'
          }
        }
      })
  })
</script>